#ifndef _CvVision_H_
#define _CvVision_H_

#include "opencv.hpp"
#include <string>

#define NO_CAPTURE			-1
#define CAPTURE_FROM_CAM	0
#define CAPTURE_FROM_AVI	1

#define USE_DEFAULT			-1
#define BGR_IMAGE			0
#define RGB_IMAGE			1
#define HSV_IMAGE			2

class CvVision
{
public:
	CvVision();
	~CvVision();

	//Camera tools
	bool captureCam();
	bool grabImage(short int inImageColor = USE_DEFAULT);

	//Video tools
	bool captureAVI(std::string inPath);
	bool retrieveImage(int inFrame, short int inImageColor = USE_DEFAULT, bool inOptimize = true);

	//Loading Image
	bool grabImage(char* inDataImage, int inWidth, int inHeight, int inChannels, int inType);

	//OpenCv processing tools
	void convertingRGB_BGR();
	void convertingBGR_RGB();
	void convertingBGR_HSV();
	void convertingHSV_BGR();
	void flipImage(short int inStyle=0);
	void changeSize(short int inFactor);
	
	//Calibrations tools
	void takePicture(char* inFileName){imwrite(inFileName, mImage );};

	//Debugging tools
	void saveImage(std::string inImageName);
	void show();					//show mImage.
	void showStream();				//show the camera stream

	//Gets
	const unsigned int getHeight() const{return mHeight;};
	const unsigned int getWidth() const{return mWidth;};
	
	const unsigned int getFPS() const{return mFPS;};
	const int getNumFrames() const{return mNumFrames;};
	const int getPosFrames() const{return mPosFrames;};
	const std::string getPath() const{return mPath;};

	const short int getCaptureType() const{return mCaptureType;};
	const short int getImageColor() const{return mImageColor;};
	void setImageColor(short int inImageColor) {mImageColor=inImageColor;};

	//Do not use
	cv::Mat& getImage() {return mImage;};
private:
	cv::VideoCapture	mCapture;
	cv::Mat				mImage;
	bool				mLoad;
	unsigned int		mHeight;
	unsigned int		mWidth;
	
	short int			mImageColor;
	short int			mCaptureType;

	short int			mSamplingFactor;

	//in case of a video
	unsigned int		mFPS;
	int					mNumFrames;
	int					mPosFrames;
	std::string			mPath;		//Contains nothing if the capture is from a cam
};

#endif
